package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zaeh {
   HashMap a = new HashMap();
   HashMap b = new HashMap();
   HashMap c = new HashMap();
   HashMap d = new HashMap();
   HashMap e = new HashMap();
   HashMap f = new HashMap();
   Workbook g = null;
   String h = null;
   String i = null;
   String j = null;
   String k = ".htm";
   String l = null;
   com.aspose.cells.b.a.d.zm m = null;
   String n = null;
   String o = null;
   String p = null;
   ArrayList q = new ArrayList();
   ArrayList r = new ArrayList();
   private zaed x = null;
   private znz y = null;
   private Style z = null;
   private HashMap A = null;
   private HashMap B = null;
   private boolean C = false;
   boolean s = false;
   String t = null;
   private HtmlSaveOptions D;
   IStreamProvider u;
   HashMap v = null;
   zaay w;
   private String E;
   private ArrayList F = new ArrayList();

   boolean a() {
      return this.C;
   }

   boolean b() {
      return this.m != null;
   }

   HtmlSaveOptions c() {
      return this.D;
   }

   zaeh(Workbook var1, String var2, String var3, com.aspose.cells.b.a.d.zm var4, HtmlSaveOptions var5) throws Exception {
      this.D = var5;
      this.g = var1;
      this.w = zka.a(var1);
      this.v = new HashMap();
      this.x = new zaed(var1);
      this.h = var3;
      this.m = var4;
      this.l = var5.getPageTitle();
      this.y = znz.a(var1);
      this.z = new Style(var1.getWorksheets());
      this.z.copy(var1.getWorksheets().D());
      String var6;
      if (var2 != null) {
         this.i = com.aspose.cells.b.a.d.zk.c(var2);
         var6 = com.aspose.cells.b.a.d.zk.d(var2);
         if (!".htm".equals(var6.toLowerCase()) && !".html".equals(var6.toLowerCase())) {
            if (!".mht".equals(var6.toLowerCase()) && !".mhtml".equals(var6.toLowerCase())) {
               this.i = com.aspose.cells.b.a.d.zk.b(var2);
            } else {
               this.i = com.aspose.cells.b.a.d.zk.c(var2);
            }
         } else {
            this.k = var6;
         }

         this.j = this.i + this.k;
         this.o = this.i + "_files";
         this.p = com.aspose.cells.b.a.d.zk.e(var2) + com.aspose.cells.b.a.d.zk.a;
         this.n = this.p + this.o + com.aspose.cells.b.a.d.zk.a;
      } else {
         var6 = this.D.getAttachedFilesDirectory();
         if (var6 != null && var6.length() > 1) {
            if (var6.charAt(var6.length() - 1) != com.aspose.cells.b.a.d.zk.a) {
               var6 = var6 + com.aspose.cells.b.a.d.zk.a;
            }

            this.o = com.aspose.cells.b.a.d.zk.e(var6);
            this.n = com.aspose.cells.b.a.d.zk.e(var6) + com.aspose.cells.b.a.d.zk.a;
         } else if (this.D.isExpImageToTempDir()) {
            this.n = com.aspose.cells.b.a.d.zk.a();
         } else if (this.D.getExportObjectListener() != null) {
            this.n = "";
         } else {
            this.n = null;
         }

         this.t = this.D.getAttachedFilesUrlPrefix();
      }

      this.u = var5.getStreamProvider();
      if (this.u == null) {
         if (this.o != null) {
            this.u = new zbpq(this.n, this.o.length() + 1);
         } else {
            this.u = new zbpq(this.n, 0);
         }
      }

      this.k();
   }

   zaed d() {
      return this.x;
   }

   znz e() {
      return this.y;
   }

   HashMap f() {
      return this.A;
   }

   void a(HashMap var1) {
      this.A = var1;
   }

   HashMap g() {
      return this.B;
   }

   void b(HashMap var1) {
      this.B = var1;
   }

   Style h() {
      return this.z;
   }

   private void k() {
      int var1;
      if (this.h != null && this.h.length() > 0) {
         Worksheet var3 = this.g.getWorksheets().get(this.h);
         if (var3 == null) {
            throw new CellsException(15, "sheet " + this.h + " does not exist");
         }

         com.aspose.cells.b.a.a.ze.a(this.r, (Object)var3);
      } else {
         Worksheet var2;
         for(var1 = 0; var1 < this.g.getWorksheets().getCount(); ++var1) {
            var2 = this.g.getWorksheets().get(var1);
            if (var2.isVisible() && (var2.getType() == 1 || var2.getType() == 2)) {
               com.aspose.cells.b.a.a.ze.a(this.r, (Object)var2);
            }
         }

         if (this.D.getExportHiddenWorksheet()) {
            for(var1 = 0; var1 < this.g.getWorksheets().getCount(); ++var1) {
               var2 = this.g.getWorksheets().get(var1);
               if (!var2.isVisible() && (var2.getType() == 1 || var2.getType() == 2)) {
                  this.r.add(var2.getIndex(), var2);
               }
            }
         }
      }

      var1 = this.r.size();
      if (var1 != 1 && var1 != 0) {
         this.C = true;
      } else {
         this.C = false;
      }

      this.l();
   }

   zafg a(zafg var1, String var2, String var3, String var4, String var5, StreamProviderOptions var6) throws Exception {
      if (var1 == null) {
         String var7 = "tabstrip.htm";
         String var8 = this.o + "/" + var7;
         var6.a = var8;
         this.u.initStream(var6);
         com.aspose.cells.b.a.d.zm var9 = var6.c;
         Encoding var10 = this.c().getEncoding();
         if (var10 == null) {
            var10 = Encoding.getUTF8();
         }

         var1 = new zafg(var9, var10);
         this.v.put(var7, var6.b == null ? var6.a : var6.b);
      } else {
         b(var1, var2, var3, var4, var5);
      }

      return var1;
   }

   zafg a(zafg var1, String var2, String var3, String var4, String var5) throws Exception {
      if (var1 == null) {
         Encoding var6 = this.c().getEncoding();
         if (var6 == null) {
            var6 = Encoding.getUTF8();
         }

         if (this.m != null) {
            var1 = new zafg(this.m, var6);
         } else {
            var1 = new zafg(this.p + this.i + this.k, var6);
         }
      } else {
         b(var1, var2, var3, var4, var5);
      }

      return var1;
   }

   public static void b(zafg var0, String var1, String var2, String var3, String var4) throws Exception {
      var0.g();
      var0.g();
      var0.b(var1);
      var0.b("Content-Location: " + var2);
      var0.b("Content-Transfer-Encoding: " + var3);
      var0.b("Content-Type: " + var4);
      var0.g();
      var0.g();
   }

   zafg b(zafg var1, String var2, String var3, String var4, String var5, StreamProviderOptions var6) throws Exception {
      if (var1 == null) {
         String var7 = "stylesheet.css";
         String var8 = this.o + "/" + var7;
         var6.a = var8;
         this.u.initStream(var6);
         com.aspose.cells.b.a.d.zm var9 = var6.c;
         Encoding var10 = this.c().getEncoding();
         if (var10 == null) {
            var10 = Encoding.getUTF8();
         }

         var1 = new zafg(var9, var10);
         this.v.put(var7, var6.b == null ? var6.a : var6.b);
      } else {
         b(var1, var2, var3, var4, var5);
      }

      return var1;
   }

   zafg c(zafg var1, String var2, String var3, String var4, String var5, StreamProviderOptions var6) throws Exception {
      if (var1 == null) {
         String var7 = "filelist.xml";
         String var8 = this.o + "/" + var7;
         var6.a = var8;
         this.u.initStream(var6);
         com.aspose.cells.b.a.d.zm var9 = var6.c;
         Encoding var10 = this.c().getEncoding();
         if (var10 == null) {
            var10 = Encoding.getUTF8();
         }

         var1 = new zafg(var9, var10);
         this.v.put(var7, var6.b == null ? var6.a : var6.b);
      } else {
         b(var1, var2, var3, var4, var5);
      }

      return var1;
   }

   zafg a(String var1, zafg var2, String var3, String var4, String var5, String var6, StreamProviderOptions var7) throws Exception {
      this.E = var4;
      (new StringBuilder()).append(this.n).append(var1).toString();
      if (var2 == null) {
         String var10 = this.o + "/" + var1;
         var7.a = var10;
         this.u.initStream(var7);
         com.aspose.cells.b.a.d.zm var11 = var7.c;
         Encoding var12 = this.c().getEncoding();
         if (var12 == null) {
            var12 = Encoding.getUTF8();
         }

         var2 = new zafg(var11, var12);
         this.v.put(var1, var7.b == null ? var7.a : var7.b);
      } else {
         b(var2, var3, var4 + var1, var5, var6);
      }

      return var2;
   }

   String a(String var1) {
      if (this.r.size() <= 1) {
         return null;
      } else {
         for(int var2 = 0; var2 < this.r.size(); ++var2) {
            Worksheet var3 = (Worksheet)this.r.get(var2);
            if (com.aspose.cells.b.a.zv.b(var3.getName(), var1)) {
               String var4 = "sheet" + zaff.a(var2 + 1, 3) + ".htm";
               return var4;
            }
         }

         return null;
      }
   }

   ArrayList i() {
      return this.F;
   }

   private void l() {
      for(int var1 = 0; var1 < this.r.size(); ++var1) {
         Worksheet var2 = (Worksheet)this.r.get(var1);
         if (var2.getHyperlinks().getCount() > 0) {
            for(int var3 = 0; var3 < var2.getHyperlinks().getCount(); ++var3) {
               Hyperlink var4 = var2.getHyperlinks().get(var3);

               try {
                  if (var4.a(this.g.getWorksheets()) == 2) {
                     com.aspose.cells.b.a.a.ze.a(this.F, (Object)var4);
                  }
               } catch (Exception var6) {
                  ;
               }
            }
         }
      }

   }

   String b(String var1) {
      if (this.n == null) {
         return "";
      } else if (this.b() && var1 == null) {
         return this.t != null ? this.t : this.n;
      } else {
         return !this.a() ? this.o + com.aspose.cells.b.a.d.zk.a : "";
      }
   }

   Workbook j() {
      return this.g;
   }
}
